package com.ittest.controller;

import com.ittest.service.UserService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    //注入service
    // @Autowired  // 本地注入

    /*@Reference过程
       1. 从zookeeper注册中心获取userService的访问url
       2. 进行远程调用RPC
       3. 将结果封装为代理对象，给变量赋值
     */
    @Reference  //dubbo的远程注入注解
    private UserService userService;

    @RequestMapping("/sayHello")
    public String sayHello(){
        return userService.sayHello();
    }

}
